'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:FinanceChoosepeopleCtrl
 * @description
 * # FinanceChoosepeopleCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('FinanceChoosepeopleCtrl', function($scope, $window, $routeParams, Util, openApi, PagingService) {
        var relModuleObj;
        var showDatas = [];
        var param = {};
        // 获取搜索所需参数以及标题信息
        relModuleObj = Util.getDataforsearch();
        param.relatedModule = relModuleObj.selectTab;
        param = angular.extend(param, relModuleObj.param || {});
        $scope.isSelectindex = -1;
        // 选择后回传的数据
        var returnData;
        $scope.isSelect = function(index) {
            return $scope.isSelectindex == index
        }
        $scope.choosePeople = function(index) {
            $scope.isSelectindex = index;
            $scope.submit()
        }
        $scope.submit = function() {
            var filterData;
            if ($scope.isSelectindex == -1) {
                Util.Toast("请选择");
                return;
            }
            if ($scope.taskList.items) {
                // 返回的字段value
                filterData = Util.filterSelectData($scope.taskList.items[$scope.isSelectindex], $scope.taskList.valuePropertys,relModuleObj.propertyName)
                    // relModuleObj包含用来回显的值以及返回的内容
                relModuleObj.filterData = filterData;
                Util.savaDataforsearch(relModuleObj)
                $window.history.back();
            }
        }
        $scope.filterSql = param.filterSql;
        $scope.search = function() {
            param.filterSql = $scope.filterSql;
            $scope.taskList = new PagingService(openApi.getRelpage, param);
        }
        $scope.search();
    });
